package com.douyang.service.impl;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.douyang.VO.SystemQuestionAnswerVO;
import com.douyang.base.model.PageResult;
import com.douyang.dto.GetSystemAnswerDTO;
import com.douyang.dto.SystemQuestionAnswerDTO;
import com.douyang.mapper.SystemQuestionAnswerMapper;
import com.douyang.pojo.SystemQuestionAnswer;
import com.douyang.service.SystemQuestionAnswerService;
import org.springframework.beans.BeanUtils;
import org.springframework.stereotype.Service;
import org.springframework.util.CollectionUtils;

import java.util.List;

/**
 * <p>
 * 服务实现类
 * </p>
 *
 * @author xiaoma
 * @since 2025-03-10
 */
@Service
public class SystemQuestionAnswerServiceImpl extends ServiceImpl<SystemQuestionAnswerMapper, SystemQuestionAnswer> implements SystemQuestionAnswerService {

    @Override
    public PageResult<SystemQuestionAnswerVO> getAllSystemList(GetSystemAnswerDTO getSystemAnswerDTO) {
        Page<SystemQuestionAnswer> page = lambdaQuery().page(getSystemAnswerDTO.getPage());

        return PageResult.of(page, s -> {
            SystemQuestionAnswerVO systemQuestionAnswerVO = new SystemQuestionAnswerVO();
            BeanUtils.copyProperties(s, systemQuestionAnswerVO);
            return systemQuestionAnswerVO;
        });
    }

        @Override
        public void addSystemAnswer (SystemQuestionAnswerDTO systemQuestionAnswerDTO){
            SystemQuestionAnswer systemQuestionAnswer = new SystemQuestionAnswer();
            BeanUtils.copyProperties(systemQuestionAnswerDTO, systemQuestionAnswer);
            saveOrUpdate(systemQuestionAnswer);
        }
    }
